Skip to main content

5.1 Penalty End Date and Removal Date Calculation

This section explains how the Penalty End Date and Removal Date are calculated for penalties associated with driver offences. These dates are derived based on a penalty's configuration and the offence details.


5.1.1 Finding the offence or Conviction Date

Before calculating the End Date or Removal Date, we determine whether to use the offence Date or Conviction Date for the calculation. This depends on the penalty's configuration in lookup table and the driver's license status.

Process Overview

  1. Penalty Lookup: Find penalty details from the lookup table using the penalty code.
  2. Date Preference: Decide whether to use the offence Date or Conviction Date:
    • If the penalty specifies a special rule for disqualified licenses and the license status is disqualified, use the Conviction Date.
    • Otherwise, fall back on the default preference (Conviction Date or offence Date).
  3. Output: Use the selected date as the base date for further calculations.

Mermaid Diagram for Finding offence or Conviction Date


5.1.2 End Date Calculation

The End Date is the date after which the penalty is no longer applicable. This is determined as follows:

Process Overview

  1. Penalty Lookup: Check if the penalty exists in lookup table. If not, the End Date is null.
  2. Check Disqualification: If the driver is pending disqualification, the End Date is also null.
  3. Date Calculation: Add the penalty's endPeriod (number of years) to the offence or Conviction Date.
  4. Output: The resulting date is the penalty's End Date.

Mermaid Diagram for End Date Calculation


5.1.3 Removal Date Calculation

The Removal Date is when the penalty record is removed from the system. It is calculated as follows:

Process Overview

  1. Penalty Lookup: If the penalty doesn't exist in the lookup table, the Removal Date is null.
  2. Date Calculation: Add the penalty's period (number of years) to the offence or Conviction Date.
  3. Output: The resulting date is the Removal Date.

Mermaid Diagram for Removal Date Calculation


Key Terms and Variables Explained

  1. Lookup Table:

    • A table containing penalty configuration for different offence codes.
    • Is present in firestore at this path: /config/lookUp/licensePenalty/codes
  2. Penalty:

    • A rule associated with a offence code.
    • Found in a lookup table using the offence code.
    • Contains:
      • endPeriod: Number of years to calculate the End Date.
      • period: Number of years to calculate the Removal Date.
      • overrideCalculationType: Rules for prioritizing Conviction Date or offence Date.
  3. offence Date:

    • The date when the offence occurred.
  4. Conviction Date:

    • The date when the driver was convicted for the offence.
  5. offence or Conviction Date:

    • The base date for calculating penalty-end date and penalty-removal date. Derived based on rules from the penalty.

Example Walkthrough

Given:

  • Penalty Code: CD40
  • offence Date: 2020-01-01
  • Conviction Date: 2021-01-01
  • Penalty Data:
    • endPeriod: 10 years
    • period: 11 years
    • overrideCalculationType: Use offence Date if Disqualified
  • License Status: Disqualified

Steps:

  1. Find penalty data for CD40 in the lookup.
  2. Check overrideCalculationType:
    • If the license is disqualified, use offence Date.
    • Else, use Conviction Date.
  3. Calculate End Date: Add 10 years to the selected date.
  4. Calculate Removal Date: Add 11 years to the selected date.

Result:

  • End Date: 2030-01-01
  • Removal Date: 2031-01-01
Status: Draft (Pending Review)
Category: Protected
Authored By: Sohan on Jan 15, 2025